import { Base } from '../../utils/base.js'

class Coupon extends Base {
  constructor() {
    super();
  }
  //商家领券中心
  getTypeList(param, cb) {
    var that = this;
    var allParams = {
      url: 'coupon/lists',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      }
    };
    this.request(allParams);
  }
  //获取优惠券信息
  getDetail(param, cb) {
    var that = this;
    var allParams = {
      url: 'member/item-info',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      }
    };
    this.request(allParams);
  }
  //好友获取优惠券信息
  getShareCouponInfo(param, cb) {
    var that = this;
    var allParams = {
      url: 'coupon/item-info',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      }
    };
    this.request(allParams);
  }
  //用户领取优惠券
  receive(param, cb) {
    var that = this;
    var allParams = {
      url: 'coupon/receive',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      }
    };
    this.request(allParams);
  }
  //我的优惠券列表
  getMyCoupons(param, cb) {
    var that = this;
    var allParams = {
      url: 'member/coupons?page='+param.page,
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      }
    };
    this.request(allParams);
  }
  //设置优惠券处于分享的状态
  setShare(param, cb){
    var that = this;
    var allParams = {
      url: 'coupon/share-link',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      }
    }
    this.request(allParams);
  }
  //好友领取优惠券
  friendReceive(param, cb) {
    var that = this;
    var allParams = {
      url: 'coupon/do-share',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      }
    }
    this.request(allParams);
  }
  //充值卡充值
  recharge(param, cb) {
    var that = this;
    var allParams = {
      url: 'card/recharge',
      data: param,
      type: 'post',
      sCallback: function (res) {
        cb && cb(res)
      }
    }
    this.request(allParams);
  }
}
export { Coupon }